package com.example.springconfigdemo.controller;

import com.example.springconfigdemo.dao.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Value("${str1}")
    private String str1;
    @Value("${str2}")
    private String str2;
    @Value("${str3}")
    private String str3;

//    @Autowired
//    private User u1;
//
//    @Autowired
//    private User u2;
    //从配置文件中获取属性值
//    @Value("${ceshi.value}")
//    private Double value;

    @Value("${mystring.value}")
    private String s;

//    @RequestMapping("/getValue")
//    public String fun1(){
//        return "value的值：" + value;
//    }

    @RequestMapping("/getValue2")
    public String fun2(){
        if(s == null){
            return "s==null";
        }else{
            return "s的值："+ s;
        }

    }

    @RequestMapping("/str")
    public String str1(){
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        return "ok";
    }

//    @RequestMapping("/user")
//    public String fun3(){
//        System.out.println(u1);
//        System.out.println(u2);
//        return "ok";
//    }

}
